package com.example.demo.controller;

import com.example.demo.mapper.UserMapper;
import com.example.demo.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api")
public class UserController {

    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(UserController.class);

    @Resource
    UserMapper userMapper;

    @GetMapping("/getusers")
    public List<User> GetUsers(){
        System.out.println("---------------开始------------------");
        log.info("---------------开始------------------");

        List<User> users = userMapper.selectList(null);
        for (User user:users){
            System.out.println(user);
        }
        return users;
    }

    @GetMapping("/code")
    public String CreatCode(){
        return "成功";
    }
}